<template>
  <div class="el-menu-vertical-demo">
    <el-aside width="200px">
      <el-menu
          :default-active="this.$store.state.menus.editableTabsValue"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
      >
        <router-link to="/index">
          <el-menu-item index="index" @click="selectMenu({name: 'index', title: '首页'})">
            <template slot="title">
              <i class="el-icon-s-home"></i>
              <span slot="title">首页</span>
            </template>
          </el-menu-item>
        </router-link>

        <el-submenu :index="menu.name" v-for="menu in menuList">
          <template slot="title">
            <i :class="menu.icon"></i>
            <span>{{ menu.title }}</span>
          </template>

          <router-link :to="item.path" v-for="item in menu.children">
            <el-menu-item :index="item.name" @click="selectMenu(item)">
              <template slot="title">
                <i :class="item.icon"></i>
                <span slot="title">{{ item.title }}</span>
              </template>
            </el-menu-item>
          </router-link>

        </el-submenu>

      </el-menu>
    </el-aside>
  </div>
</template>

<script>
export default {
  name: "SideMenu",
  data() {
    return {}
  },
  methods: {
    //标签 显示历史记录
    selectMenu(item) {
      this.$store.commit("addTabs", item)
    },
  },
  computed: {
    menuList: {
      get() {
        return this.$store.state.menus.menuList
      }
    }
  },
  watch: {
    menuList: function () {
    }
  }
}
</script>


<style scoped>

.el-menu-vertical-demo {
  background-color: rgb(84, 92, 100);
  height: 100%;
}

a {
  text-decoration: none;
}
</style>
